import { defineStore } from "pinia";
import defaultSetting from "@/settings";

export const useSettingStore = defineStore({
  id: "setting",
  state: () => ({
    title: defaultSetting.title,
    isDynamicTitle: defaultSetting.isDynamicTitle, // 是否使用动态标题
    isNavBar: defaultSetting.isNavBar,
    isManager:false
  }),
  actions: {
    setTitle: function (title) {
      if (this.isDynamicTitle) {
        this.title = title;
      } else {
        this.title = defaultSetting.title;
      }
      document.title = this.title;
    },
    setIsManager:function (val) {
      this.isManager = val
    }
  },
  //数据持久化配置 这里是当前所有变量都持久化
  persist:true
});
